﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ex1.StringToHex
{
    class StringToHex
    {
        private static string ConvertStringToHex(string str)
        {
            Encoding utf16le = Encoding.UTF8;
            byte[] bytes = utf16le.GetBytes(str);

            StringBuilder result = new StringBuilder();
            for (int i = 0; i < bytes.Length; i++)
            {
                result.Append(string.Format("\\x{0:x}", bytes[i]));
            }
            return result.ToString();
        }

        static void Main(string[] args)
        {
            string inputString = "Hi!";
            Console.WriteLine(ConvertStringToHex(inputString));
        }
    }
}
